/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:1,
        hide:true
    },
    {
        id: 'id',
        title: 'ID',
        type: 'int',
        columnClass: 'text-center width-100',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'profit',
        title: '盈利',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'comprehensive',
        title: '综合管理费',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'defer',
        title: '递延费',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'commission',
        title: '佣金',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'stampTax',
        title: '印花税',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'createTime',
        title: '日期',
        type: 'date',
        format: 'yyyy-MM-dd',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: true,
        fastQueryType: 'range'

    },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'dayReport/list.json',
    exportURL:ncGlobal.adminRoot + 'dayReport/export.json',
    exportFileName: '日报',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int: ["id"],Timestamp:["createTime"],BigDecimal:["profit","comprehensive","defer","commission","stampTax"]},
    tools:'refresh|faseQuery|export[excel]',

};

var grid = $.fn.DtGrid.init(dtGridOption);
grid.fastQueryParameters = new Object();

//排序
grid.sortParameter.columnId = ['asc_id'];
grid.sortParameter.sortType = 1;
//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {
        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['lk_real_name'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }

    //外部可调用
    return {
        bindEvent: _bindEvent
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});